//
//  VipCardLeaveTableViewCell.m
//  fitnessmanage
//
//  Created by 众拳科技 on 2017/11/1.
//  Copyright © 2017年 zongquankeji. All rights reserved.
//

#import "VipCardLeaveTableViewCell.h"

@implementation VipCardLeaveTableViewCell

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        self.backgroundColor = CSWhiteColor;
        
        /**
         类型图片
         */
        UIImageView *typeImageView = [[UIImageView alloc] init];
        typeImageView.image = [UIImage imageNamed:@"card_label_ing"];
        [self.contentView addSubview:typeImageView];
        self.typeImageView = typeImageView;
        
        /**
         原因
         */
        UILabel *reasonLabel = [[UILabel alloc] init];
        reasonLabel.text = @"过节";
        reasonLabel.font = [UIFont boldSystemFontOfSize:16.0];
        [self.contentView addSubview:reasonLabel];
        self.reasonLabel = reasonLabel;
        
        /**
         时间Label
         */
        UILabel *timeLabel = [[UILabel alloc] init];
        timeLabel.text = @"时间：2017-11-30 至 2017-12-01";
        timeLabel.font = MidFont;
        timeLabel.textColor = CSColorFromRGBA(0x666666,0.5);
        [self.contentView addSubview:timeLabel];
        self.timeLabel = timeLabel;
        
        
        /**
         收费
         */
        UILabel *chargeLabel = [[UILabel alloc] init];
        chargeLabel.text = @"收费：12元";
        chargeLabel.font = MidBigFont;
        chargeLabel.textColor = CSColorFromRGB(0x666666);
        [self.contentView addSubview:chargeLabel];
        self.chargeLabel = chargeLabel;
        
        /**
         备注
         */
        UILabel *noteLabel = [[UILabel alloc] init];
        noteLabel.text = @"备注：哈哈哈哈";
        noteLabel.font = MidBigFont;
        noteLabel.textColor = CSColorFromRGB(0x666666);
        [self.contentView addSubview:noteLabel];
        self.noteLabel = noteLabel;
        
        
        /**
         线条
         */
        UIView *lineView = [[UIView alloc] init];
        lineView.backgroundColor = LineBackGroundColor;
        [self.contentView addSubview:lineView];
        self.lineView = lineView;
        
        UIButton *rightBtn = [[UIButton alloc] init];
        [rightBtn setImage:@"card_icon_more"];
        [self.contentView addSubview:rightBtn];
        self.rightBtn = rightBtn;
        
        [self setConstraints];
    }
    
    return self;
}

-(void)setConstraints{

    
    /**
     类型图片
     */
    [self.typeImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.left.mas_equalTo(self.contentView).offset(20);
    }];
    
    /**
     原因
     */
    [self.reasonLabel mas_remakeConstraints:^(MASConstraintMaker *make) {

        make.left.mas_equalTo(self.typeImageView.mas_right).offset(10);
        
        make.centerY.mas_equalTo(self.typeImageView);
    }];

    /**
     时间Label
     */
    [self.timeLabel mas_remakeConstraints:^(MASConstraintMaker *make) {

        make.left.mas_equalTo(self.typeImageView);

        make.top.mas_equalTo(self.reasonLabel.mas_bottom).offset(6);
    }];


    [self.lineView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self.typeImageView);
        
        make.height.mas_equalTo(1);
        
        make.top.mas_equalTo(self.timeLabel.mas_bottom).offset(15);
        
        make.right.mas_equalTo(self.rightBtn);
    }];
    
    
    /**
     收费
     */
    [self.chargeLabel mas_remakeConstraints:^(MASConstraintMaker *make) {

        make.left.mas_equalTo(self.timeLabel);

        make.top.mas_equalTo(self.lineView.mas_bottom).offset(20);
    }];

    /**
     备注
     */
    [self.noteLabel mas_remakeConstraints:^(MASConstraintMaker *make) {

        make.left.mas_equalTo(self.chargeLabel);

        make.top.mas_equalTo(self.chargeLabel.mas_bottom).offset(10);
        
        make.bottom.mas_equalTo(self.contentView).offset(-20);
    }];
    
    [self.rightBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.right.mas_equalTo(self.contentView).offset(-20);
        
        make.centerY.mas_equalTo(self.reasonLabel.mas_bottom).offset(5);
    }];
}
@end
